<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%shop_users}}".
 *
 * @property int $id
 * @property int $status 状态200正常99禁用
 * @property int $created_at 注册时间
 * @property int $updated_at 修改时间
 * @property string $token 登录令牌
 * @property string $key 登录秘钥
 * @property string|null $nickname 昵称
 * @property int|null $avatar_file_id 头像
 * @property string $mobile 手机
 * @property string|null $password 登录密码
 * @property string|null $pwd_back
 * @property int $gender
 * @property string|null $mp_openid
 * @property string|null $mp_appid
 * @property string|null $unionid
 * @property string|null $pa_openid 公众号
 */
class ShopUsers extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%shop_users}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['status', 'created_at', 'updated_at', 'token', 'key', 'nickname', 'avatar_file_id', 'mobile', 'password', 'pwd_back', 'gender', 'mp_openid', 'mp_appid', 'unionid', 'pa_openid'], 'trim'],
            [['status', 'created_at', 'updated_at', 'avatar_file_id', 'gender'], 'integer'],
            [['created_at', 'updated_at', 'token', 'key', 'mobile'], 'required'],
            [['password', 'pwd_back'], 'string'],
            [['token', 'key'], 'string', 'max' => 32],
            [['nickname', 'mp_openid', 'mp_appid', 'unionid', 'pa_openid'], 'string', 'max' => 180],
            [['mobile'], 'string', 'max' => 11],
            [['status'], 'default', 'value' => 200],
            [['nickname', 'avatar_file_id', 'password', 'pwd_back', 'mp_openid', 'mp_appid', 'unionid', 'pa_openid'], 'default', 'value' => null],
            [['gender'], 'default', 'value' => 0],
            [['token'], 'unique'],
            [['mobile'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'status' => Yii::t('app', '状态200正常99禁用'),
            'created_at' => Yii::t('app', '注册时间'),
            'updated_at' => Yii::t('app', '修改时间'),
            'token' => Yii::t('app', '登录令牌'),
            'key' => Yii::t('app', '登录秘钥'),
            'nickname' => Yii::t('app', '昵称'),
            'avatar_file_id' => Yii::t('app', '头像'),
            'mobile' => Yii::t('app', '手机'),
            'password' => Yii::t('app', '登录密码'),
            'pwd_back' => Yii::t('app', 'Pwd Back'),
            'gender' => Yii::t('app', 'Gender'),
            'mp_openid' => Yii::t('app', 'Mp Openid'),
            'mp_appid' => Yii::t('app', 'Mp Appid'),
            'unionid' => Yii::t('app', 'Unionid'),
            'pa_openid' => Yii::t('app', '公众号'),
        ];
    }
}
